<!DOCTYPE unspecified PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http//www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php的查询</title>
</head>
<body>
<?php

header("Content-Type:text/html; charset=utf-8");
//连接数据库
$conn=mysql_connect('localhost:3306','root','root') or die("连接数据库失败");
$db=mysql_select_db("test");
$query="select * from php_user";
$result=mysql_query($query);
mysql_query('SET NAMES utf-8');
$data=mysql_fetch_array($result);
if(mysql_num_rows($result)>0){
	?>
<br/>
<div style="text-align: center">PHP单表增删改查demo</div>
<hr/>
<table border="1" align="center" background="#99CCFFLL">
	<tr>
		<td align="center">ID</td>
		<td align="center">username</td>
		<td align="center">address</td>
		<td align="center">tel</td>
		<td align="center">content</td>
		<td align="center">dowork</td>
	</tr>
	<?php
	do {
		echo "<tr>";
		echo "<td>$data[id]</td>";
		echo "<td>$data[username]</td>";
		echo "<td>$data[address]</td>";
		echo "<td>$data[tel]</td>";
		echo "<td>$data[content]</td>";
		echo "<td><a href='add.html'>添加用户</a>
				 <a href='del.php?uid=$data[id]'>删除用户</a>
				 <a href='update.html?id=$data[id]&username=$data[username]&address=$data[address]&tel=$data[tel]&content=$data[content]'>修改用户</a></td>";
		echo "</tr>";
	}
	while ($data=mysql_fetch_array($result));
}
else
{
	echo "没有数据";
} ?>
</table>
</body>
</html>
